/**
 * 
 */
package jmine.tec.di.type;


import bancosys.tec.persist.base.enumx.EnumUtils;

/**
 * {@link TypeConverter} para enums de java
 * 
 * @author takeshi
 */
public final class JavaEnumTypeConverter implements TypeConverter<Enum<?>> {
    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public Enum convert(String value, Class desiredType) throws TypeConvertionException {
        return EnumUtils.getEnumByValue(desiredType, value);
    }

    /**
     * {@inheritDoc}
     */
    public boolean isTypeCompatible(Class<?> type) {
        return type.isEnum();
    }
}